--
-- Author: mm
-- Date: 2018-03-19 14:55:37
--
-- NewguildMemberHeadRender 对应 Node_list_head.csb
-- 工会成员头像render

local NewTeamMemberHeadRender = require("app.team.views.renders.NewTeamMemberHeadRender")

local ClassRef = app.mvc.createRenderClass(...)

--data =
function ClassRef.createWithData(data, node)
    local sprite = ClassRef.extend(node or cc.CSLoader:createNode(Res.NewGuildMemberHeadNode))
    if node == nil then
        ccui.Helper:doLayout(sprite)
    end
    sprite:init(data)
    return sprite
end
function ClassRef.create(node)
    return ClassRef.createWithData(nil, node)
end

function ClassRef:init(data)
    self.super.init(self, data)
    self:setContentSize(self._ui.Panel:getContentSize())
    self._headIcon = NewTeamMemberHeadRender.create( self._ui.head )

    self:refresh()
end

-- data = guildMemberVo/guildApplicantVo 结构
function ClassRef:refresh()
    if self._data then
        self:setVisible( true )
        local data = self._data

        self._headIcon:setData( data:getMemberInfo() ) -- 头像
        self._ui.Text_name:setString( data:getMemberName() ) -- 名字
        self._ui.combat_num:setString( data:getMemberCombatPower() ) -- 战斗力

        if data:isOnline() then -- 在线？
            self._ui.Text_state:setString( L("text_10700009") )
        else
            self._ui.Text_state:setString( data:offlineStr() )
        end
        self._ui.icon2:setVisible( data:isOnline() )
        self._ui.icon2_n:setVisible( not data:isOnline() )
    else
        self:setVisible( false )
    end
end

function ClassRef:onBtnClick(cb)
    self._onClick = cb
end

return ClassRef
